<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>壁纸APP - 详情页面</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --primary-color: #007AFF;
            --bg-color: #f5f5f5;
            --text-color: #333;
            --card-bg: #fff;
            --border-color: #f5f5f5;
            --secondary-text: #999;
            --shadow-color: rgba(0,0,0,0.1);
            --highlight-color: #f0f7ff;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            transition: all 0.3s ease;
        }
        
        body.dark-theme {
            --primary-color: #3a9bff;
            --bg-color: #121212;
            --text-color: #f5f5f5;
            --card-bg: #1e1e1e;
            --border-color: #2c2c2c;
            --secondary-text: #aaa;
            --shadow-color: rgba(0,0,0,0.3);
            --highlight-color: #1a2c42;
        }

        /* 顶部标题栏 */
        .header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 44px;
            background: var(--card-bg);
            padding: 8px 16px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: 0 1px 3px var(--shadow-color);
            z-index: 100;
            transition: background-color 0.3s ease;
        }

        .back-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary-color);
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .back-btn:active {
            background-color: var(--highlight-color);
            transform: scale(0.95);
        }

        .header h1 {
            font-size: 18px;
            font-weight: 500;
        }
        
        .theme-toggle {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary-color);
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .theme-toggle:active {
            background-color: var(--highlight-color);
            transform: scale(0.95);
        }

        /* 主内容区 */
        .main-content {
            margin-top: 44px;
            margin-bottom: 49px;
            overflow-y: auto;
            padding: 16px;
        }

        /* 筛选和排序区域 */
        .filter-container {
            background-color: var(--card-bg);
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 16px;
            box-shadow: 0 2px 6px var(--shadow-color);
        }

        .filter-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
        }

        .filter-title {
            font-size: 16px;
            font-weight: 500;
        }

        .filter-actions {
            display: flex;
            gap: 10px;
        }

        .filter-btn, .sort-btn {
            background-color: var(--highlight-color);
            color: var(--primary-color);
            border: none;
            padding: 6px 12px;
            border-radius: 16px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .filter-btn:active, .sort-btn:active {
            transform: scale(0.95);
            background-color: var(--primary-color);
            color: white;
        }

        .search-box {
            display: flex;
            background: var(--bg-color);
            border-radius: 20px;
            padding: 8px 16px;
            margin-top: 12px;
        }

        .search-box input {
            flex: 1;
            border: none;
            background: transparent;
            outline: none;
            font-size: 14px;
            color: var(--text-color);
        }

        .search-box input::placeholder {
            color: var(--secondary-text);
        }

        .search-icon {
            color: var(--secondary-text);
            margin-right: 8px;
        }

        /* 瀑布流布局 */
        .masonry-container {
            column-count: 2;
            column-gap: 10px;
            margin-top: 16px;
        }

        .masonry-item {
            break-inside: avoid;
            margin-bottom: 10px;
            position: relative;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 2px 6px var(--shadow-color);
        }

        .masonry-item img {
            width: 100%;
            display: block;
            border-radius: 12px;
        }

        .item-overlay {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            padding: 10px;
            background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
            color: white;
            font-size: 12px;
        }

        .item-actions {
            position: absolute;
            top: 8px;
            right: 8px;
            display: flex;
            gap: 8px;
        }

        .action-btn {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: rgba(255,255,255,0.2);
            backdrop-filter: blur(5px);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .action-btn:active {
            transform: scale(0.9);
            background: rgba(255,255,255,0.3);
        }

        /* 空状态提示 */
        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 40px 20px;
            text-align: center;
            color: var(--secondary-text);
        }

        .empty-icon {
            font-size: 60px;
            margin-bottom: 20px;
            color: var(--border-color);
        }

        .empty-text {
            font-size: 16px;
            margin-bottom: 10px;
        }

        .empty-subtext {
            font-size: 14px;
            opacity: 0.8;
        }

        /* 底部导航 */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 49px;
            background: var(--card-bg);
            display: flex;
            justify-content: space-around;
            align-items: center;
            box-shadow: 0 -1px 3px var(--shadow-color);
            transition: background-color 0.3s ease;
        }

        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: var(--secondary-text);
            font-size: 12px;
            text-decoration: none;
            padding: 8px 0;
            width: 33.33%;
            transition: color 0.3s ease;
        }

        .nav-item.active {
            color: var(--primary-color);
        }

        /* 加载更多指示器 */
        .load-more {
            text-align: center;
            padding: 20px 0;
            color: var(--secondary-text);
            font-size: 14px;
        }

        .spinner {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 2px solid rgba(0,0,0,0.1);
            border-top-color: var(--primary-color);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-right: 8px;
            vertical-align: middle;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <!-- 顶部标题栏 -->
    <div class="header">
        <div class="back-btn" id="backBtn">
            <i class="fas fa-chevron-left"></i>
        </div>
        <h1 id="pageTitle">详情页面</h1>
        <div class="theme-toggle" id="themeToggle">
            <i class="fas fa-moon"></i>
        </div>
    </div>

    <!-- 主内容区 -->
    <div class="main-content">
        <!-- 筛选和排序区域 -->
        <div class="filter-container">
            <div class="filter-header">
                <div class="filter-title" id="filterTitle">全部壁纸</div>
                <div class="filter-actions">
                    <button class="filter-btn">
                        <i class="fas fa-filter"></i> 筛选
                    </button>
                    <button class="sort-btn">
                        <i class="fas fa-sort"></i> 排序
                    </button>
                </div>
            </div>
            <div class="search-box">
                <div class="search-icon">
                    <i class="fas fa-search"></i>
                </div>
                <input type="text" placeholder="搜索壁纸..." id="searchInput">
            </div>
        </div>

        <!-- 瀑布流内容区域 -->
        <div class="masonry-container" id="masonryContainer">
            <!-- 动态生成的内容将在这里显示 -->
        </div>

        <!-- 空状态提示 -->
        <div class="empty-state" id="emptyState" style="display: none;">
            <div class="empty-icon">
                <i class="fas fa-image"></i>
            </div>
            <div class="empty-text">暂无内容</div>
            <div class="empty-subtext" id="emptySubtext">您还没有收藏任何壁纸</div>
        </div>

        <!-- 加载更多指示器 -->
        <div class="load-more" id="loadMore" style="display: none;">
            <span class="spinner"></span> 正在加载更多...
        </div>
    </div>

    <!-- 底部导航 -->
    <div class="bottom-nav">
        <a href="index.html" class="nav-item">
            <i class="fas fa-home"></i>
            <span>首页</span>
        </a>
        <a href="category.html" class="nav-item">
            <i class="fas fa-th-large"></i>
            <span>分类</span>
        </a>
        <a href="my.html" class="nav-item active">
            <i class="fas fa-user"></i>
            <span>我的</span>
        </a>
    </div>

    <script>
        // 获取URL参数
        function getQueryParam(param) {
            const urlParams = new URLSearchParams(window.location.search);
            return urlParams.get(param);
        }

        // 页面类型
        const pageType = getQueryParam('type') || 'favorite';
        const pageTitle = document.getElementById('pageTitle');
        const filterTitle = document.getElementById('filterTitle');
        const emptySubtext = document.getElementById('emptySubtext');
        const masonryContainer = document.getElementById('masonryContainer');
        const emptyState = document.getElementById('emptyState');
        const loadMore = document.getElementById('loadMore');

        // 根据页面类型设置标题和空状态文本
        function setupPageByType() {
            switch(pageType) {
                case 'favorite':
                    pageTitle.textContent = '我喜欢的壁纸';
                    filterTitle.textContent = '我的收藏';
                    emptySubtext.textContent = '您还没有收藏任何壁纸';
                    break;
                case 'download':
                    pageTitle.textContent = '已下载壁纸';
                    filterTitle.textContent = '下载记录';
                    emptySubtext.textContent = '您还没有下载任何壁纸';
                    break;
                case 'history':
                    pageTitle.textContent = '浏览历史';
                    filterTitle.textContent = '最近浏览';
                    emptySubtext.textContent = '您还没有浏览记录';
                    break;
                default:
                    pageTitle.textContent = '详情页面';
                    filterTitle.textContent = '全部壁纸';
                    emptySubtext.textContent = '暂无内容';
            }
        }

        // 模拟数据
        const mockImages = [
            { id: 1, url: 'https://picsum.photos/400/600?random=1', title: '自然风景壁纸' },
            { id: 2, url: 'https://picsum.photos/400/800?random=2', title: '城市夜景壁纸' },
            { id: 3, url: 'https://picsum.photos/400/500?random=3', title: '海洋风光壁纸' },
            { id: 4, url: 'https://picsum.photos/400/700?random=4', title: '山川河流壁纸' },
            { id: 5, url: 'https://picsum.photos/400/600?random=5', title: '花卉植物壁纸' },
            { id: 6, url: 'https://picsum.photos/400/550?random=6', title: '动物世界壁纸' },
            { id: 7, url: 'https://picsum.photos/400/650?random=7', title: '星空宇宙壁纸' },
            { id: 8, url: 'https://picsum.photos/400/750?random=8', title: '建筑设计壁纸' }
        ];

        // 根据页面类型获取不同的数据
        function getDataByPageType() {
            // 这里模拟不同页面类型的数据，实际应用中应该从服务器获取
            if (pageType === 'favorite') {
                return mockImages.filter(img => img.id % 2 === 0); // 偶数ID作为收藏
            } else if (pageType === 'download') {
                return mockImages.filter(img => img.id % 3 === 0); // 被3整除的ID作为下载
            } else if (pageType === 'history') {
                return mockImages; // 所有图片作为历史记录
            }
            return [];
        }

        // 渲染瀑布流内容
        function renderMasonryItems(items) {
            if (items.length === 0) {
                emptyState.style.display = 'flex';
                return;
            }

            emptyState.style.display = 'none';
            masonryContainer.innerHTML = '';

            items.forEach(item => {
                const itemElement = document.createElement('div');
                itemElement.className = 'masonry-item';
                itemElement.innerHTML = `
                    <img src="${item.url}" alt="${item.title}">
                    <div class="item-overlay">${item.title}</div>
                    <div class="item-actions">
                        <div class="action-btn">
                            <i class="fas fa-heart"></i>
                        </div>
                        <div class="action-btn">
                            <i class="fas fa-download"></i>
                        </div>
                    </div>
                `;
                masonryContainer.appendChild(itemElement);
            });
        }

        // 模拟加载更多数据
        function loadMoreData() {
            loadMore.style.display = 'block';
            
            // 模拟网络请求延迟
            setTimeout(() => {
                const currentItems = document.querySelectorAll('.masonry-item').length;
                const newItems = mockImages.map(item => ({
                    ...item,
                    id: item.id + currentItems,
                    url: `https://picsum.photos/400/${500 + Math.floor(Math.random() * 300)}?random=${item.id + currentItems}`,
                    title: `${item.title} ${currentItems + 1}`
                }));
                
                newItems.forEach(item => {
                    const itemElement = document.createElement('div');
                    itemElement.className = 'masonry-item';
                    itemElement.innerHTML = `
                        <img src="${item.url}" alt="${item.title}">
                        <div class="item-overlay">${item.title}</div>
                        <div class="item-actions">
                            <div class="action-btn">
                                <i class="fas fa-heart"></i>
                            </div>
                            <div class="action-btn">
                                <i class="fas fa-download"></i>
                            </div>
                        </div>
                    `;
                    masonryContainer.appendChild(itemElement);
                });
                
                loadMore.style.display = 'none';
            }, 1500);
        }

        // 初始化页面
        function initPage() {
            setupPageByType();
            const data = getDataByPageType();
            renderMasonryItems(data);

            // 监听滚动事件，实现无限滚动
            window.addEventListener('scroll', () => {
                if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight - 200) {
                    // 当滚动到接近底部时加载更多
                    if (loadMore.style.display === 'none') {
                        loadMoreData();
                    }
                }
            });
        }

        // 返回按钮事件
        document.getElementById('backBtn').addEventListener('click', () => {
            window.history.back();
        });

        // 搜索功能
        document.getElementById('searchInput').addEventListener('input', (e) => {
            const searchTerm = e.target.value.toLowerCase();
            const data = getDataByPageType();
            const filteredData = data.filter(item => 
                item.title.toLowerCase().includes(searchTerm)
            );
            renderMasonryItems(filteredData);
        });

        // 主题切换功能
        const themeToggle = document.getElementById('themeToggle');
        const body = document.body;
        
        // 检查本地存储中的主题设置
        if (localStorage.getItem('darkTheme') === 'true') {
            body.classList.add('dark-theme');
            themeToggle.innerHTML = '<i class="fas fa-sun"></i>';
        }
        
        // 主题切换事件
        themeToggle.addEventListener('click', function() {
            body.classList.toggle('dark-theme');
            
            if (body.classList.contains('dark-theme')) {
                localStorage.setItem('darkTheme', 'true');
                themeToggle.innerHTML = '<i class="fas fa-sun"></i>';
            } else {
                localStorage.setItem('darkTheme', 'false');
                themeToggle.innerHTML = '<i class="fas fa-moon"></i>';
            }
        });

        // 页面加载完成后初始化
        window.addEventListener('DOMContentLoaded', initPage);
    </script>
</body>
</html>